package com.ywcq.netty.httpserver.listeners;

import java.util.Iterator;
import java.util.Set;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.event.ApplicationStartingEvent;
import org.springframework.context.ConfigurableApplicationContext;

import com.ywcq.netty.httpserver.helloworld.Config;
import com.ywcq.netty.httpserver.helloworld.HttpHelloWorldServer;


public class ApplicationListener 
implements org.springframework.context.ApplicationListener<ApplicationReadyEvent>
{
	
	@Override
	public void onApplicationEvent(ApplicationReadyEvent event) 
	{
		try 
		{
			ConfigurableApplicationContext context = event.getApplicationContext();
			Config config = context.getBean(com.ywcq.netty.httpserver.helloworld.Config.class);
			HttpHelloWorldServer server = new HttpHelloWorldServer();
			server.init(config);
			server.startServer();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
